package com.easyCode.mysql.sqlBuilder.sqlInfo;

import com.easyCode.sqlBuilder.SqlInfo;
import com.easyCode.sqlBuilder.sqlUtil.SqlBuildUtil;
import lombok.Data;

/**
 * 负责提供字符集方面sql构建的信息
 *
 * @author 大忽悠
 * @create 2022/11/8 19:23
 */
@Data
public class CharsetSqlInfo implements SqlInfo {
    /**
     * 默认字符集
     */
    protected String charset = "utf8";
    /**
     * 字符集默认排序规则
     */
    protected String collate = "utf8_general_ci";

    /**
     * @param charset 字符集
     * @param collate 字符集比较规则
     */
    public void setCharsetAndCollate(String charset, String collate) {
        this.charset = charset;
        this.collate = collate;
    }

    /**
     * @return 返回根据自身sqlInfo构建的部分sql语句
     */
    @Override
    public String buildSql() {
        return SqlBuildUtil.buildSql("CHARACTER SET", SqlBuildUtil.wrapSqlVal(charset), "COLLATE", SqlBuildUtil.wrapSqlVal(collate));
    }

    public static CharsetSqlInfo getDefault(){
        return new CharsetSqlInfo();
    }
}
